import request from './request'

/**
 * 获取预算列表
 */
export const getBudgets = () => {
  return request({
    url: '/api/budgets',
    method: 'get'
  })
}

/**
 * 获取预算详情
 * @param {number} id - 预算ID
 */
export const getBudgetDetail = (id) => {
  return request({
    url: `/api/budgets/${id}`,
    method: 'get'
  })
}

/**
 * 创建预算
 * @param {object} data - 预算数据
 */
export const createBudget = (data) => {
  return request({
    url: '/api/budgets',
    method: 'post',
    data
  })
}

/**
 * 更新预算
 * @param {number} id - 预算ID
 * @param {object} data - 更新数据
 */
export const updateBudget = (id, data) => {
  return request({
    url: `/api/budgets/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除预算
 * @param {number} id - 预算ID
 */
export const deleteBudget = (id) => {
  return request({
    url: `/api/budgets/${id}`,
    method: 'delete'
  })
}

/**
 * 获取支出列表
 * @param {object} params - 查询参数
 */
export const getExpenses = (params) => {
  return request({
    url: '/api/expenses',
    method: 'get',
    params
  })
}

/**
 * 创建支出
 * @param {object} data - 支出数据
 */
export const createExpense = (data) => {
  return request({
    url: '/api/expenses',
    method: 'post',
    data
  })
}

/**
 * 更新支出
 * @param {number} id - 支出ID
 * @param {object} data - 更新数据
 */
export const updateExpense = (id, data) => {
  return request({
    url: `/api/expenses/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除支出
 * @param {number} id - 支出ID
 */
export const deleteExpense = (id) => {
  return request({
    url: `/api/expenses/${id}`,
    method: 'delete'
  })
}